package mn.idax.exchange.otc.service;

import com.alibaba.fastjson.JSON;
import mn.idax.exchange.otc.dto.ChatProtocol;
import org.atmosphere.cpr.Broadcaster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 这个类暂时没用
 */

@Service
public class ChatPubService {

    private static final Logger logger = LoggerFactory.getLogger(ChatPubService.class);

    /**
     * 这里只处理买卖双方发布的消息
     *
     * @param message
     */
    public void receiveMessage(String message) {
        logger.info("----receiveMessageFromRedis:{}----", message);
        ChatProtocol chatProtocol = JSON.parseObject(message, ChatProtocol.class);
        Broadcaster broadcaster = ChatRoomService.broadcasterFactory.lookup(chatProtocol.getOrderId(), true);
        if (broadcaster != null) {
            broadcaster.broadcast(message);
        }
    }
}
